<?php
class Grid_Support_Support extends OeZend_Widget_Grid {
    public function init() {

        $collectionColumn = new OeZend_Widget_Grid_Collection_Column();

        $idColumn = new OeZend_Widget_Grid_Column('id');
        $idColumn->setFilter('Combobox');
        $idColumn->addAttribute(array('class' => 'center', 'width' => '4%'));

        $titleColumn = new OeZend_Widget_Grid_Column('supporter_name');
        $titleColumn->setLabel('Supporter');

        $acountColumn = new OeZend_Widget_Grid_Column('account');
        $acountColumn->setLabel('Account');

        $phoneColumn = new OeZend_Widget_Grid_Column('phone');
        $phoneColumn->setLabel('Phone');

        $sortingNumberColumn = new OeZend_Widget_Grid_Column('sorting_number');

        $typeColumn = new OeZend_Widget_Grid_Column('type');
        $typeColumn->setLabel('Type');
        $typeColumn->addAttribute(array('class' => 'center', 'width' => '15%'));

        $statusColumn = new OeZend_Widget_Grid_Column('status_label');
        $statusColumn->setFilter('Combobox');
        $statusColumn->setLabel('Public');
        $callBackFunction = function ($rs) {
                                $class = 'ajax-link-must-confirm popup hint  label';
		  						return ($rs['status'] == Model_DbTable_ProductCategory::STATUS_ACTIVE)
     			  						? '<a href="##" class="'. $class .' label-success" data-ajax-to="/admin/support/change-value?p=public&id=' . $rs['id'] . '" data-must-confirm-msg="Do you want change this ?" title="Thay đổi" data-after-ajax="No">Yes</a>'
     			  						: '<a href="##" class="'. $class .' label-warning" data-ajax-to="/admin/support/change-value?p=public&id=' . $rs['id'] . '" data-must-confirm-msg="Do you want change this ?" title="Thay đổi" data-after-ajax="Yes">No</a>';
							};
        $statusColumn->setContent(new OeZend_Widget_Grid_Column_Content_CallBack($callBackFunction));
        $statusColumn->addAttribute(array('class' => 'center', 'width' => '4%'));

        $linkColumn = new OeZend_Widget_Grid_Column();
        $linkColumn->setLabel('Edit');
        $link = '<a href="/admin/support/update/id/${id}"><i class="icon-edit"></i></a>';
        $linkColumn->setContent(new OeZend_Widget_Grid_Column_Content_Template($link));
        $linkColumn->addAttribute(array('class' => 'center', 'width' => '4%'));

        $linkDeleteColumn = new OeZend_Widget_Grid_Column();
        $linkDeleteColumn->setLabel('Delete');
        $linkDelete = '<a href="/admin/support/delete/id/${id}" class="must-confirm"><i class="icon-remove"></i></a>';
        $linkDeleteColumn->setContent(new OeZend_Widget_Grid_Column_Content_Template($linkDelete));
        $linkDeleteColumn->addAttribute(array('class' => 'center', 'width' => '4%'));

        $collectionColumn->addColumns(
                  array(
                        $idColumn,
                        $titleColumn,
                        $acountColumn,
                        $phoneColumn,
                        $typeColumn,
                        $sortingNumberColumn,
                        $statusColumn,
                        $linkColumn,
                        $linkDeleteColumn
                       ));

        $this->setCollectionColumn($collectionColumn);
    }
}


